/**
 ****************************************************************************
 * Copyright (C) Marcelo F. Ochoa. All rights reserved.                      *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Apache Software License *
 * version 1.1, a copy of which has been included  with this distribution in *
 * the LICENSE file.                                                         *
 */
 
package com.prism.toolkit.http;

import com.prism.toolkit.Jxtp;

import java.io.PrintWriter;
import java.io.StringWriter;

import java.sql.Date;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Locale;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;


public class JxtpHttpServletResponse implements HttpServletResponse {
    Logger log = Logger.getLogger(JxtpHttpServletResponse.class);

    public JxtpHttpServletResponse() {
        log.debug(".JxtpHttpServletResponse() called.");
    }

    public void addCookie(Cookie cookie) {
        Jxtp
        .sendCookie(cookie.getName(), cookie.getValue(), new Date(System.currentTimeMillis()), cookie
                        .getPath(), cookie.getDomain(), cookie.getSecure());
    }

    public boolean containsHeader(String string) {
        return false;
    }

    public String encodeURL(String string) {
        return null;
    }

    public String encodeRedirectURL(String string) {
        return null;
    }

    public String encodeUrl(String string) {
        return null;
    }

    public String encodeRedirectUrl(String string) {
        return null;
    }

    public void sendError(int i, String string) {
      Jxtp.setHeader("Status-Code",i+" "+string);
    }

    public void sendError(int i) {
        Jxtp.setHeader("Status-Code",""+i);
    }

    public void sendRedirect(String string) {
        Jxtp.redirecUrl(string);
    }

    public void setDateHeader(String string, long l) {
        DateFormat df =
            new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", java.util
                                             .Locale.US);
        df.format(new Date(l));
        Jxtp.setHeader(string, df.toString());
    }

    public void addDateHeader(String string, long l) {
        setDateHeader(string, l);
    }

    public void setHeader(String str1, String str2) {
        Jxtp.setHeader(str1, str2);
    }

    public void addHeader(String str1, String str2) {
        setHeader(str1, str2);
    }

    public void setIntHeader(String string, int i) {
        setHeader(string, "" + i);
    }

    public void addIntHeader(String string, int i) {
        setIntHeader(string, i);
    }

    public void setStatus(int i) {
        Jxtp.setHeader("Status", "" + i);
    }

    public void setStatus(int i, String string) {
    }

    public String getCharacterEncoding() {
        return Jxtp.getEncoding();
    }

    public String getContentType() {
        return Jxtp.getContentType();
    }

    public ServletOutputStream getOutputStream() {
        return null;
    }

    public PrintWriter getWriter() {
        return new PrintWriter(Jxtp.getWriter());
    }

    public StringBuffer getBuffer() {
        StringWriter sw = (StringWriter)Jxtp.getWriter();
        return sw.getBuffer();
    }

    public void setCharacterEncoding(String string) {
        Jxtp.setEncoding(string);
    }

    public void setContentLength(int i) {
    }

    public void setContentType(String string) {
        Jxtp.setContentType(string);
    }

    public void setBufferSize(int i) {
      
    }

    public int getBufferSize() {
        return 0;
    }

    public void flushBuffer() {
    }

    public void resetBuffer() {
    }

    public boolean isCommitted() {
        return false;
    }

    public void reset() {
    }

    public void setLocale(Locale locale) {
    }

    public Locale getLocale() {
        return null;
    }
}
